/******************************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd                       */
/*                                                                            */
/*  NAME      = sybase_base_type.h                                            */
/*  NOTE      =                                                               */
/*  DATE      = 2015/05/27 by zhengxd                                         */
/******************************************************************************/
#ifndef _SBASE_BASE_TYPE_H_
#define _SBASE_BASE_TYPE_H_

#include "frmem.h"
#include "frstr.h"
#include "frcomm.h"
#include "frlist.h"
#include "frhash2.h"
#include "frlog.h"
#include "iconv2utf8.h"
#include "frsutl.h"
#include "frhex_dump.h"

#include "conntrack.h"
#include "module.h"
#include "frct_comm.h"
#include "frdb_cursor.h"
#include "frreport_comm.h"
#include "frbyte_buffer.h"
#include "frtds_convert.h"

/* TDS5.0 msgtype */
#define TDS50_MSGTYPE_NUL                   0
#define TDS50_MSGTYPE_BUF_LANG              1  //language command
#define TDS50_MSGTYPE_BUF_LOGIN             2  //login record
#define TDS50_MSGTYPE_BUF_RPC               3  //remote procedure call command
#define TDS50_MSGTYPE_BUF_RESPONSE          4  //response to a command
#define TDS50_MSGTYPE_BUF_UNFMT             5  //raw unformatted data
#define TDS50_MSGTYPE_BUF_ATTN              6  //non-expedited attention request
#define TDS50_MSGTYPE_BUF_BULK              7  //bulk binary data.
#define TDS50_MSGTYPE_BUF_SETUP             8  //protocol request to setup another logical channel
#define TDS50_MSGTYPE_BUF_CLOSE             9  //protocol request to close a logical channel
#define TDS50_MSGTYPE_BUF_ERROR             10 //resource error was detected while attempting to setup or use a logical channel
#define TDS50_MSGTYPE_BUF_PROTACK           11 //protocol acknowledgment associated with the logical channel windowing protocol
#define TDS50_MSGTYPE_BUF_ECHO              12 //protocol request to echo the data contained in the buffer
#define TDS50_MSGTYPE_BUF_LOGOUT            13 //protocol request to logout an active logical channel
#define TDS50_MSGTYPE_BUF_ENDPARAM          14 //What is this??? todo
#define TDS50_MSGTYPE_BUF_NORMAL            15 //This packet contains a tokenized TDS request or response
#define TDS50_MSGTYPE_BUF_URGENT            16 //This packet contains an urgent tokenized TDS request or response.
#define TDS50_MSGTYPE_BUF_MIGRATE           17 //This packet contains a migration protocol message
#define TDS50_MSGTYPE_BUF_CMDSEQ_NORMAL     24 //SQL Anywhere CMDSEQ protocol
#define TDS50_MSGTYPE_BUF_CMDSEQ_LOGIN      25 //SQL Anywhere CMDSEQ protocol
#define TDS50_MSGTYPE_BUF_CMDSEQ_LIVENESS   26 //SQL Anywhere CMDSEQ protocol
#define TDS50_MSGTYPE_BUF_CMDSEQ_RESERVED1  27 //SQL Anywhere CMDSEQ protocol
#define TDS50_MSGTYPE_BUF_CMDSEQ_RESEVERD2  28 //SQL Anywhere CMDSEQ protocol

/* TDS5.0 token 类型 */
#define TDS50_TOKEN_ALTCONTROL              0xAF //obsolete
#define TDS50_TOKEN_ALTFMT                  0xA8
//#define TDS50_TOKEN_ALTFMT2                 0x?? //token not implemented yet
#define TDS50_TOKEN_ALTNAME                 0xA7
#define TDS50_TOKEN_ALTROW                  0xD3
//#define TDS50_TOKEN_ALTROW2                 0x?? //token not implemented yet
#define TDS50_TOKEN_CAPABILITY              0xE2
#define TDS50_TOKEN_COLFMT                  0xA1 //obsolete
#define TDS50_TOKEN_COLFMTOLD               0x2A //obsolete
#define TDS50_TOKEN_COLINFO                 0xA5
#define TDS50_TOKEN_COLINFO2                0x20
#define TDS50_TOKEN_COLNAME                 0xA0 //obsolete
#define TDS50_TOKEN_CONTROL                 0xAE
#define TDS50_TOKEN_CURCLOSE                0x80
#define TDS50_TOKEN_CURDECLARE              0x86
#define TDS50_TOKEN_CURDECLARE2             0x23
#define TDS50_TOKEN_CURDECLARE3             0x10
#define TDS50_TOKEN_CURDELETE               0x81
#define TDS50_TOKEN_CURFETCH                0x82
#define TDS50_TOKEN_CURINFO                 0x83
#define TDS50_TOKEN_CURINFO2                0x87
#define TDS50_TOKEN_CURINFO3                0x88
#define TDS50_TOKEN_CUROPEN                 0x84
#define TDS50_TOKEN_CURUPDATE               0x85
#define TDS50_TOKEN_DBRPC                   0xE6
#define TDS50_TOKEN_DBRPC2                  0xE8
#define TDS50_TOKEN_DEBUGCMD                0x60 //obsolete
#define TDS50_TOKEN_DONE                    0xFD
#define TDS50_TOKEN_DONEINPROC              0xFF
#define TDS50_TOKEN_DONEPROC                0xFE
#define TDS50_TOKEN_DYNAMIC                 0xE7
#define TDS50_TOKEN_DYNAMIC2                0x62
#define TDS50_TOKEN_EED                     0xE5
#define TDS50_TOKEN_ENVCHANGE               0xE3
#define TDS50_TOKEN_ERROR                   0xAA //obsolete
#define TDS50_TOKEN_EVENTNOTICE             0xA2
#define TDS50_TOKEN_INFO                    0xAB //obsolete
#define TDS50_TOKEN_KEY                     0xCA
#define TDS50_TOKEN_LANGUAGE                0x21
#define TDS50_TOKEN_LOGINACK                0xAD
#define TDS50_TOKEN_LOGOUT                  0x71
#define TDS50_TOKEN_MSG                     0x65
#define TDS50_TOKEN_OFFSET                  0x78
#define TDS50_TOKEN_OPTIONCMD               0xA6
#define TDS50_TOKEN_OPTIONCMD2              0x63 //reserved
#define TDS50_TOKEN_ORDERBY                 0xA9
#define TDS50_TOKEN_ORDERBY2                0x22
#define TDS50_TOKEN_PARAMFMT                0xEC
#define TDS50_TOKEN_PARAMFMT2               0x20
#define TDS50_TOKEN_PARAMS                  0xD7
#define TDS50_TOKEN_PROCID                  0x7C //obsolete
#define TDS50_TOKEN_RETURNSTATUS            0x79
#define TDS50_TOKEN_RETURNVALUE             0xAC //obsolete
#define TDS50_TOKEN_RPC                     0xE0 //obsolete
#define TDS50_TOKEN_ROW                     0xD1
#define TDS50_TOKEN_ROWFMT                  0xEE
#define TDS50_TOKEN_ROWFMT2                 0x61
#define TDS50_TOKEN_TABNAME                 0xA4

#define FRTDS_LOGIN_START                     0
#define FRTDS_LOGIN_SUCCEED                   5
#define FRTDS_LOGIN_FAIL                      6
#define FRTDS_LOGIN_NEGOTIATE                 7

#define FRTDS_MAX_NAME                        30

#endif
